import $http from "./axios";
import Qs from "qs";
import axios from "axios";
// 请求方法  content-type类型  参数类型

//post form/json json
export function postRequest(url: string, data: string | object | []) {
    return $http.post(url, Qs.stringify(data));
}

//post form object
export function postObjRequest(url: string, data: string | object) {
    return $http.post(url, data);
}

export function getRequest(url: string, data: any) {
    return $http.get(url, data);
}

//  Content-Type:multipart/form-data
export function postMultipartRequest(url: string, data: string | object) {
    return $http.post(url, data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}

//blob格式下载
export function postRequestBlob(url: string, data: string | object) {
    return axios.post(url, Qs.stringify(data), {
        responseType: 'blob'
    });
}

//object提交、blob格式下载
export function postObjectReturnBlob(url: string, data: string | object) {
    return axios.post(url, data, {
        responseType: 'blob'
    });
}
